#include <bits/stdc++.h>
using namespace std;
const int maxn=61*30+5;
int cntIdx;
bool dp[32][62][maxn],graph[62][62];
short int track[32][62][maxn];
pair<int,int> Scnt[62];
int main()
{
int M,A[32];
cin>>M;
for(int i=1;i<=M;++i)
cin>>A[i];
sort(A+1,A+M+1);
dp[0][0][0]=true;
for(int i=1;i<=M;++i)
for(int j=i;j<=61;++j)
for(int k=(j*(j-1))>>1;k<maxn;++k)
{
for(int m=1;m<=j;++m)
if(k>=m*A[i] && dp[i-1][j-m][k-m*A[i]])
{
dp[i][j][k]=true;
track[i][j][k]=m;
break;
}
}
int N=M;
while(!dp[M][N][(N*(N-1))>>1]) ++N;
cout<<N<<"\n";
for(int i=M,j=N,k=(N*(N-1))>>1;i;--i){
int c=track[i][j][k];
j-=c;
k-=c*A[i];
for(int j=0;j<c;++j){
++cntIdx;
Scnt[cntIdx]=make_pair(A[i],cntIdx);
}
}
for(int i=1;i<=N;++i){
sort(Scnt+1,Scnt+cntIdx+1);
for(int j=i+1;j<=i+Scnt[i].first;++j) graph[Scnt[i].second][Scnt[j].second]=true;
for(int j=i+Scnt[i].first+1;j<=N;++j) graph[Scnt[j].second][Scnt[i].second]=true,--Scnt[j].first;
Scnt[i].first=-1;
}
for(int i=1;i<=N;++i){
for(int j=1;j<=N;++j)
cout<<(graph[i][j]?1:0);
cout<<"\n";
}
return 0;
}/*1695971235.0255582*/
144. Binary Tree Preorder Traversal | 137. Single Number II |
130. Surrounded Regions | 129. Sum Root to Leaf Numbers |
120. Triangle | 102. Binary Tree Level Order Traversal |
96. Unique Binary Search Trees | 75. Sort Colors |
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |